package cn.edu.suda.ada.database.exception;

import java.sql.SQLException;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * 数据库异常
 * 
 * @author JiangJun
 *
 */
public class DatabaseException extends Throwable {

	private static final long serialVersionUID = 7417340125083340794L;
	/**
	 * 日志
	 */
	protected static Logger logger = LogManager.getLogger("edu.suda.ada.database");
	
	public DatabaseException(String msg, Throwable e) {
		logger.error(msg, e);
		System.exit(-1);
	}
	
	public DatabaseException(String msg) {
		logger.error(msg);
		System.exit(-1);
	}
	
	public DatabaseException(Throwable e) {
		if (e instanceof SQLException) {
			logger.error("无法执行数据库语句！", e);
		} 
		else {
			logger.error(e);
		}
		System.exit(-1);
	}

}
